package com.docwei.thansgank.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.docwei.thansgank.R;
import com.docwei.thansgank.callback.ResultBean;

import java.util.List;

/**
 * Created by tobo on 17/7/24.
 */

public class MyFuliAdapter extends RecyclerView.Adapter<MyFuliAdapter.MyViewHolder> {
    public List<ResultBean.GankBean> mList;
    public Context mContext;
    public MyFuliAdapter(List<ResultBean.GankBean> list, Context context) {
        mList = list;
        mContext=context;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(mContext).inflate(R.layout.item_fuli,parent, false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        ResultBean.GankBean bean = mList.get(position);
        holder.mTv_desc.setText(bean.getDesc());

        Glide.with(mContext)
                .load(bean.getUrl()+"?imageView2/0/w/100")
                .placeholder(R.mipmap.ic_launcher)
                .into(holder.mIv_meizi);


    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    static class MyViewHolder extends RecyclerView.ViewHolder{
        ImageView mIv_meizi;
        TextView mTv_desc;
        public MyViewHolder(View itemView) {
            super(itemView);
            mIv_meizi= (ImageView) itemView.findViewById(R.id.iv_meizi);
            mTv_desc= (TextView) itemView.findViewById(R.id.desc);
        }
    }
}
